<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
 <head>
  <title>inputEx - Group Usage</title>

<!-- YUI CSS -->
<link rel="stylesheet" type="text/css" href="../lib/yui/reset-fonts/reset-fonts.css">
<link rel="stylesheet" type="text/css" href="../lib/yui/container/assets/container.css"> 
<link rel="stylesheet" type="text/css" href="../lib/yui/assets/skins/sam/skin.css">

<!-- InputEx CSS -->
<link type='text/css' rel='stylesheet' href='../css/inputEx.css' />

<!-- Demo CSS -->
<link rel="stylesheet" type="text/css" href="css/demo.css"/>
<link rel="stylesheet" type="text/css" href="css/dpSyntaxHighlighter.css">

 </head>

 <body>

<h1>inputEx - Group interactions</h1>

<!-- YUI Library -->
<script type="text/javascript" src="../lib/yui/utilities/utilities.js"></script>
<script type="text/javascript" src="../lib/yui/container/container-min.js"></script>
<script type="text/javascript" src="../lib/yui/json/json-min.js"></script>


<!-- InputEx -->
<script src="../js/inputex.js"  type='text/javascript'></script>
<script src="../js/mixins/choice.js"  type='text/javascript'></script>
<script src="../js/Field.js"  type='text/javascript'></script>
<script src="../js/Group.js"  type='text/javascript'></script>
<script src="../js/fields/StringField.js"  type='text/javascript'></script>
<script src="../js/fields/CheckBox.js"  type='text/javascript'></script>
<script src="../js/fields/SelectField.js"  type='text/javascript'></script>
<script src="../js/fields/EmailField.js"  type='text/javascript'></script>
<script src="../js/fields/ListField.js"  type='text/javascript'></script>
<script src="../js/fields/UrlField.js"  type='text/javascript'></script>


<script src="js/dpSyntaxHighlighter.js"></script>
<script src="inputex-examples.js"></script>




<!-- Example 1 -->
<div class='exampleDiv'>
 <h2>Using a checkbox to show/hide another field</h2>
 <p>Use an action</p>
 <div class='demoContainer' id='container1'></div>
 <div class='codeContainer'>
  <textarea name="code" class="JScript">
		inputEx({
			type: "group",
	   	parentEl: 'container1',
	   	fields: [
	       {
				   type: 'boolean', // inputex type
					name: 'toggler',
				   value: true,
					rightLabel: 'Stay anonymous',
				   interactions: [
				       {
				          valueTrigger: false, // this action will run when this field value is set to false
				          actions: [
				             {
				                name: 'username', // name of the field on which the action should run
				                action: 'show' // name of the method to run on the field instance !
				             }
				          ]
				       },
				       {
				          valueTrigger: true, // when set to true:
				          actions: [
				             {
				                name: 'username', 
				                action: 'hide'
				             },
										 {
						            name: 'username', // name of the field on which the action should run
						            action: 'clear' // name of the method to run on the field instance !
						         }
				          ]
				       }
				   ]
				},
	         {type: "string", name: "username", label: "Enter your name" }
	      ]
	   });
  </textarea>
 </div>
</div>





<!-- Example 2 -->
<div class='exampleDiv'>
 <h2>Basic Group Interactions</h2>
 <p>Toggle a field</p>
 <div class='demoContainer' id='container2'></div>
 <div class='codeContainer'>
  <textarea name="code" class="JScript">
		new inputEx.Group({ 
		   parentEl: 'container2',

		   fields: [
		       {
					   type: 'boolean', // inputex type
						name: 'toggler',
					   value: true,
						rightLabel: 'Check this box to toggle the enabled field',
					   interactions: [
					       {
					          valueTrigger: true, // this action will run when this field value is set to true
					          actions: [
					             {
					                name: 'group1', // name of the field on which the action should run
					                action: 'disable' // name of the method to run on the field instance !
					             },
					             {
					                name: 'group2', 
					                action: 'enable'
					             }
					          ]
					       },
					       {
					          valueTrigger: false, // when set to false:
					          actions: [
					             {
					                name: 'group1', 
					                action: 'enable'
					             },
					             {
					                name: 'group2', 
					                action: 'disable'
					             }
					          ]
					       }
					   ]
				},
		      {
					   type: 'group',
				      name: 'group1',
				      fields: [ 
								{ type: 'select', label: 'Title',name: 'title', choices: [{ value : 'Mr' }, { value: 'Mrs' }, { value: 'Ms' }] },
								{ label: 'Firstname', name: 'firstname', required: true, value:'Jacques' },
								{ label: 'Lastname', name: 'lastname', value:'Dupont' },
								{ type:'email', label: 'Email', name: 'email'}
						]
				},
		      {
				   type: 'group',
				   name: 'group2',
				   fields: [
						{type: 'url', label: "Website",  name: 'myUrl' }
					]
				}
		   ]
		});
  </textarea>
 </div>
</div>




<!-- Example 3 -->
<div class='exampleDiv'>
 <h2>Basic Group Interactions</h2>
 <p>Toggle a field</p>
 <div class='demoContainer' id='container3'></div>
 <div class='codeContainer'>
  <textarea name="code" class="JScript">
		new inputEx.Group({ 
		   parentEl: 'container3',

		   fields: [
		       {
							type: 'select', 
							label: 'Select your country',
							choices: [{ value: "France" }, { value: "USA" }],
							interactions: [
								{
									valueTrigger: "France",
									actions: [
										{
											name: "franceCitiesSelect",
											action: "show"
										},
										{
											name: "USACitiesSelect",
											action: "hide"
										},
									]
								},
								{
									valueTrigger: "USA",
									actions: [
										{
											name: "franceCitiesSelect",
											action: "hide"
										},
										{
											name: "USACitiesSelect",
											action: "show"
										},
									]
								}
							]
					 },
				   {type: 'select', label: 'Select your city', name: 'franceCitiesSelect', choices: [{ value : "Paris" }, { value: "Lyon" }, { value: "Marseille" }] },
				   {type: 'select', label: 'Select your city', name: 'USACitiesSelect', choices: [{ value: "NewYork" }, { value: "Chicago" }, { value: "LA" }, { value: "San Francisco" }] }
		   ]
		});
  </textarea>
 </div>
</div>

 </body>
</html>